import rxAjax from '@/assets/ajax.js';
let FormBoListApi = {};

FormBoListApi.formBoListInterface=function(apiKey,params){
    let url = "/api-system/system/core/sysInterfaceApi/executeApi?apiKey="+apiKey;
    return rxAjax.postJson(url,params).then(res => {
        return res;
    });
}
FormBoListApi.formBoListInvoke=function(alias,params){
    var url="/api-form/form/core/formInvokeScript/invoke/"+alias;
    return  rxAjax.postJson(url,params).then(res => {
        return res
    })
}
FormBoListApi.queryForJson=function(key,params) {
    var paramJson={params:JSON.stringify(params)};
    var url= "/api-form/form/core/formCustomQuery/queryForJson_"+key;
    return rxAjax.post(url,paramJson).then (res => {
        return res
    });
}
FormBoListApi.getBolistByKey=function(conf) {
    let url= '/api-form/form/core/formBoList/' + conf.key +'/dialog?isMobile=1';
    if(conf.params){
        url+="&" + conf.params;
    }
    if(conf.pmtAlias){
        url+="&pmtAlias=" +conf.pmtAlias;
    }
    /**
     * 如果参数中存在appId将appId设置进请求头
     */
    let config = {}
    return rxAjax.get(url,config).then (res => {
        return res
    });
}
FormBoListApi.isDeleteByFormSolAlias=function(parameter){
    let url = '/api-form/form/core/formEntRelation/isDeleteByFormSolAlias';
    return rxAjax.postJson(url,parameter).then (res => {
        return res
    });
}
FormBoListApi.formSolutionRemoveById=function(parameter){
    let url= '/api-form/form/core/formSolution/removeById';
    return rxAjax.postJson(url,parameter).then (res => {
        return res
    });
}
FormBoListApi.removeSolutionById=function(parameter){
    let url = '/api-form/form/core/formSolution/removeById';
    return rxAjax.postJson(url,parameter).then (res => {
        return res
    });
}
//按钮前置条件验证
FormBoListApi.validPreByButton=function(preCondConfig,rows){
    var url =  '/api-form/form/core/formBoList/validPreByButton';
    rows=rows || [];
    return rxAjax.postJson(url,{config:preCondConfig,rows:rows}).then (res => {
        return res
    });
}
export default FormBoListApi
